package com.yanqu.road.utils.config;


import java.util.ArrayList;
import java.util.List;

public class Config {
    static boolean debug;
    static boolean migrate;
    static String webConfigFile;

    static int[] ignoreCode = {102, 105, 106, 113, 150, 205, 301, 310, 601, 801, 812, 1201, 1403, 1454, 1510, 1601, 1701, 1202, 2001, 2601, 2603, 2605, 3110, 6101, 6107};

    static List<Long> connectCrossId = new ArrayList<>();

    static public boolean isDebug() {
        return debug;
    }

    static public boolean isMigrate() {
        return migrate;
    }

    public static void setDebug(boolean b) {
        debug = b;
    }

    static void setMigrate(boolean b) {
        migrate = b;
    }

    public static String getWebConfigFile() {
        return webConfigFile;
    }

    public static void setWebConfigFile(String webConfigFile) {
        Config.webConfigFile = webConfigFile;
    }

    static public void ParseArgs(String[] args) {
        for (String arg : args) {
            String[] stringArray = arg.split("=");
            if (stringArray.length != 2) {
                continue;
            }
            if (stringArray[0].equals("--debug")) {
                if (stringArray[1].equals("true")) {
                    setDebug(true);
                }
            }
            if (stringArray[0].equals("--migrate")) {
                if (stringArray[1].equals("true")) {
                    setMigrate(true);
                }
            }
            if (stringArray[0].equals("--web")) {
                setWebConfigFile(stringArray[1]);
            }
        }
    }
    static public boolean isIgnore(int code) {
        for (int i : ignoreCode) {
            if (code % 10000 == i) {
                return true;
            }
        }
        return false;
    }

    public static List<Long> getConnectCrossId() {
        return connectCrossId;
    }

    public static boolean contains(long serverId) {
        return connectCrossId.contains(serverId);
    }

    public static void setConnectCrossId(List<Long> connectCrossId) {
        Config.connectCrossId = connectCrossId;
    }
}
